//载入基础页面
{extend name="common/base" /}

//页面单独CSS
{block name="CustomCSS"}
<link rel="stylesheet" href="__STATIC__/vendors/css/datatables/datatables.min.css">

{/block}

//页面单独JS
{block name="CustomJS"}
<script src="__STATIC__/vendors/js/datatables/datatables.min.js"></script>
<script src="__STATIC__/vendors/js/datatables/dataTables.buttons.min.js"></script>
<script src="__STATIC__/vendors/js/datatables/jszip.min.js"></script>
<script src="__STATIC__/vendors/js/datatables/buttons.html5.min.js"></script>
<script src="__STATIC__/vendors/js/datatables/pdfmake.min.js"></script>
<script src="__STATIC__/vendors/js/datatables/vfs_fonts.js"></script>
<script src="__STATIC__/vendors/js/datatables/buttons.print.min.js"></script>
<script src="__STATIC__/vendors/js/noty/noty.min.js"></script>
<script src="__STATIC__/vendors/js/clipboard/clipboard.min.js"></script>
<script type="text/javascript">
    (function ($) {
    'use strict';
    // ------------------------------------------------------- //
    // Auto Hide
    // ------------------------------------------------------ //    
        $(function () {
            //定义表格
            var table = $('#table').DataTable({
                language: {
                    "url": "__STATIC__/vendors/js/datatables/cn.json"
                },
                lengthMenu: [
                    [10, 15, 20, -1],
                    [10, 15, 20, "所有"]
                ],//分页数目
                stateSave: true,
                order: [[ 0, 'desc' ]],
                columnDefs: [
                    { "orderable": false, "targets": [9]}//禁止排序
                ]
            });
        });
    })(jQuery);

    //提交删除链接
    function urlSubmit(url){
        $.post(url, function(data, status){
            if (status == "success") {
                if (data == "ok") {
                    //提交成功后调用
                    new Noty({
                        type: "success",
                        layout: "topRight",
                        text: "成功删除一条数据",
                        progressBar: true,
                        timeout: 2500,
                        animation: {
                            open: "animated bounceInRight",
                            close: "animated bounceOutRight"
                        },
                        callbacks: {
                            afterShow: function() {
                                window.location.reload();
                            },
                        }
                    }).show();
                }else{
                    //提交失败后调用
                    new Noty({
                        type: "error",
                        layout: "topRight",
                        text: "数据删除失败",
                        progressBar: true,
                        timeout: 2500,
                        animation: {
                            open: "animated bounceInRight",
                            close: "animated bounceOutRight"
                        },
                        callbacks: {
                            afterShow: function() {
                            },
                        }
                    }).show();
                }
            }
        });
    };

    //打开detail模态框
    $('#modal').on('hidden.bs.modal', function (e) {
            $(this).find('.modal-body').html(' 等待结果，请稍后...');
            $(this).removeData('bs.modal');
        }).on('show.bs.modal', function (e) {
            var button = $(e.relatedTarget);
            var modal = $(this);
            modal.find('.modal-content').load(button.data("remote"));
        });

    //复制日报
    var clipboard = new ClipboardJS('.copy');
    clipboard.on('success', function(e) {
        new Noty({
            type: "success",
            layout: "topRight",
            text: "复制成功，去粘贴吧！",
            progressBar: true,
            timeout: 2500,
            animation: {
                open: "animated bounceInRight",
                close: "animated bounceOutRight"
            }
        }).show();
    });
</script>
{/block}

//页面名称
{block name="PageName"}
网销每日线索管理
{/block}

//自定义Modal
{block name="Modal"}
<!-- Begin Centered Modal -->
<div id="modal" class="modal fade">
    <div class="modal-dialog modal-dialog-centered modal-lg">
        <div class="modal-content">
            
                    读取中。。。
               
        </div>
    </div>
    </div>
<!-- End Centered Modal -->
{/block}

//主页面
{block name="main"}
<div class="row">
    <div class="col-xl-12">
        <!-- Export -->
        <div class="widget has-shadow">
        	<div class="widget-header bordered d-flex align-items-center">
                <h2>网销每日线索管理</h2>
                <button type="button" class="btn btn-primary" onclick="javascript:window.location.href='{:url('internet/create')}'"/>添加</button>
            </div>
            <div class="widget-body">
                <div class="table-responsive">
                    <table id="table" class="table mb-0">
                        <thead>
                            <tr>
                                <th>日期</th>
                                <th>之家线索</th>
                                <th>之家邀约</th>
                                <th>之家订单</th>
                                <th>易车线索</th>
                                <th>易车邀约</th>
                                <th>易车订单</th>
                                <th>其它线索</th>
                                <th>当日交车</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        	{volist name="visitorData" id="list"}
                            <tr>
                                <td>{$list.create_date|date='Y/m/d'}</td>
                                <td>{$list.autohome_count}</td>
                                <td>{$list.autohome_invite}</td>
                                <td>{$list.autohome_order}</td>
                                <td>{$list.yiche_count}</td>
                                <td>{$list.yiche_invite}</td>
                                <td>{$list.yiche_order}</td>
                                <td>{$list.other_count}</td>
                                <td>{$list.today_delivery}</td>
                                <td class="td-actions">
                                    <div class="btn-group" role="group">
                                        <button type="button" class="btn btn-primary btn-sm mr-1 mb-2" data-toggle="modal" data-remote="{:url('internet/log',['id' => $list.id])}" data-target="#modal">日报</button>
                                        <button type="button" class="btn btn-info btn-sm mr-1 mb-2" data-toggle="modal" data-remote="{:url('internet/read',['id' => $list.id])}" data-target="#modal">详情</button>
                                        <button type="button" class="btn btn-warning btn-sm mr-1 mb-2"  onclick="javascript:window.location.href='{:url('Internet/edit',['id' => $list.id])}'">编辑</button>
                                        <button type="button" class="btn btn-danger btn-sm mr-1 mb-2" onClick="urlSubmit('{:url('Internet/delete',['id' => $list.id])}')">删除</button>
                                    </div>
                                </td>
                            </tr>
                            {/volist}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- End Export -->
    </div>
</div>

<!-- End Centered Modal -->
{/block}

